Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt in to stricter TypeScript checks #1422

Merged
merged 3 commits into from
May 5, 2023
Merged

Opt in to stricter TypeScript checks #1422

merged 3 commits into from
May 5, 2023

Conversation

wycats
Copy link
Contributor

@wycats wycats commented May 4, 2023

Enable strictest TS settings and fix lints

  • exactOptionalPropertyTypes
  • noPropertyAccessFromIndexSignature
  • noImplicitOverride

This commit also cleans up deprecated lints, migrates older lints to
n/ and sets up the import lint plugins needed for a good importing
experience.

There's a lot of changes in this commit, but most of it is minor tweaks
to deal with stylistic issues raised by lints.

The biggest substantive changes were required by
exactOptionalPropertyTypes and noPropertyAccessFromIndexSignature.
Both of these strict settings revealed many places where our code didn't
clearly handle missing values and nulls, and this commit adds the
necessary checks.

Some common patterns:

  • Migrate C-style for loops to for/of loops, which eliminates nulls
  • Pervasive use of the (already existing) PresentArray pattern and its
    utilities. Added getFirst and getLast utilities, as well as some
    variations on the present array checks.
  • Used ? to propagate undefined in testing situations where undefined
    would fail equality checks anyway.

@wycats wycats changed the title Add exactOptionalPropertyTypes Opt in to stricter TypeScript checks May 4, 2023
@wycats wycats force-pushed the chore/stricter-ts branch 2 times, most recently from dd43f67 to 95edfd1 Compare May 4, 2023 04:00
- exactOptionalPropertyTypes
- noPropertyAccessFromIndexSignature
- noImplicitOverride

This commit also cleans up deprecated lints, migrates older lints to
`n/` and sets up the import lint plugins needed for a good importing
experience.

There's a lot of changes in this commit, but most of it is minor tweaks
to deal with stylistic issues raised by lints.

The biggest substantive changes were required by
`exactOptionalPropertyTypes` and `noPropertyAccessFromIndexSignature`.
Both of these strict settings revealed many places where our code didn't
clearly handle missing values and nulls, and this commit adds the
necessary checks.

Some common patterns:

- Migrate C-style for loops to for/of loops, which eliminates nulls
- Pervasive use of the (already existing) `PresentArray` pattern and its
  utilities. Added `getFirst` and `getLast` utilities, as well as some
  variations on the present array checks.
- Used `?` to propagate undefined in testing situations where undefined
  would fail equality checks anyway.
@wycats wycats force-pushed the chore/stricter-ts branch 3 times, most recently from f6bea85 to c27416b Compare May 5, 2023 05:58
@wycats wycats marked this pull request as ready for review May 5, 2023 19:52
@wycats wycats merged commit b613617 into master May 5, 2023
@wycats wycats deleted the chore/stricter-ts branch May 5, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants